package com.ruoyi.project.bajiaostar.jbhWemember.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bajiaostar.jbhWemember.domain.JbhWemember;
import com.ruoyi.project.bajiaostar.jbhWemember.service.IJbhWememberService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 会员信息Controller
 * 
 * @author 写烧糊
 * @date 2024-07-18
 */
@Controller
@RequestMapping("/bajiaostar/jbhWemember")
public class JbhWememberController extends BaseController
{
    private String prefix = "bajiaostar/jbhWemember";

    @Autowired
    private IJbhWememberService jbhWememberService;

    @RequiresPermissions("bajiaostar:jbhWemember:view")
    @GetMapping()
    public String jbhWemember()
    {
        return prefix + "/jbhWemember";
    }

    /**
     * 查询会员信息列表
     */
    @RequiresPermissions("bajiaostar:jbhWemember:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JbhWemember jbhWemember)
    {
        startPage();
        List<JbhWemember> list = jbhWememberService.selectJbhWememberList(jbhWemember);
        return getDataTable(list);
    }

    /**
     * 导出会员信息列表
     */
    @RequiresPermissions("bajiaostar:jbhWemember:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JbhWemember jbhWemember)
    {
        List<JbhWemember> list = jbhWememberService.selectJbhWememberList(jbhWemember);
        ExcelUtil<JbhWemember> util = new ExcelUtil<JbhWemember>(JbhWemember.class);
        return util.exportExcel(list, "jbhWemember",null);
    }

    /**
     * 新增会员信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存会员信息
     */
    @RequiresPermissions("bajiaostar:jbhWemember:add")
    @Log(title = "会员信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JbhWemember jbhWemember)
    {
        return toAjax(jbhWememberService.insertJbhWemember(jbhWemember));
    }

    /**
     * 修改会员信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JbhWemember jbhWemember = jbhWememberService.selectJbhWememberById(id);
        mmap.put("jbhWemember", jbhWemember);
        return prefix + "/edit";
    }

    /**
     * 修改保存会员信息
     */
    @RequiresPermissions("bajiaostar:jbhWemember:edit")
    @Log(title = "会员信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JbhWemember jbhWemember)
    {
        return toAjax(jbhWememberService.updateJbhWemember(jbhWemember));
    }

    /**
     * 删除会员信息
     */
    @RequiresPermissions("bajiaostar:jbhWemember:remove")
    @Log(title = "会员信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jbhWememberService.deleteJbhWememberByIds(ids));
    }
}
